<template>
  <div class="info-box">
    <h3>{{getInfolist.title}}</h3>
    <p class="futitle">
      <span>发表时间:{{getInfolist.add_time | dateFormat}}</span>
      <span>点击{{getInfolist.click}}次</span>
    </p>
    <hr>
    <!-- 伸缩图片区 -->
    <div class="photo-grid">
      <vue-preview :slides="list" @close="handleClose"></vue-preview>
    </div>
    <!-- 内容区 -->
    <div class="content" v-html="getInfolist.content"></div>
    <comment :id="id"></comment>
  </div>
</template>
<script>
import { toast } from "mint-ui";
import comment from "../suncompoments/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      getInfolist: {},
      list: []
    };
  },
  created() {
    this.getphotosInfo();
    this.getThumbs();
  },
  methods: {
    getphotosInfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(res => {
        var res = res.body;
        if (res.status === 0) {
          this.getInfolist = res.message[0];
        } else {
          toast("获取失败");
        }
      });
    },
    getThumbs() {
      this.$http.get("api/getthumimages/" + this.id).then(res => {
        var res = res.body;
        if (res.status === 0) {
          res.message.forEach(item => {
            item.msrc = item.src;
            item.w = 600;
            item.h = 600;
          });
          this.list = res.message;
        } else {
          toast("获取失败");
        }
      });
    },
    handleClose() {}
  },
  components: {
    comment
  }
};
</script>
<style lang="scss">
.info-box {
  padding: 4px;
  h3 {
    color: #26a2ff;
    padding: 15px;
    font-size: 15px;
    text-align: center;
  }
  .futitle {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
  .my-gallery{
    display: flex;
    flex-wrap: wrap;
    figure{
      margin: 0;
      padding: 0 3px;
      width: 33.333%;
      img{
        width: 100%;
      }
    }
  }
}
</style>